.class public Lcom/felhr/usbserial/UsbSerialDevice$WriteThread;
.super Ljava/lang/Thread;
.source "UsbSerialDevice.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/felhr/usbserial/UsbSerialDevice;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x4
    name = "WriteThread"
.end annotation


# instance fields
.field private outEndpoint:Landroid/hardware/usb/UsbEndpoint;

.field final synthetic this$0:Lcom/felhr/usbserial/UsbSerialDevice;

.field private working:Ljava/util/concurrent/atomic/AtomicBoolean;


# direct methods
.method public constructor <init>(Lcom/felhr/usbserial/UsbSerialDevice;)V
    .locals 1

    .line 297
    iput-object p1, p0, Lcom/felhr/usbserial/UsbSerialDevice$WriteThread;->this$0:Lcom/felhr/usbserial/UsbSerialDevice;

    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    .line 298
    new-instance p1, Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v0, 0x1

    invoke-direct {p1, v0}, Ljava/util/concurrent/atomic/AtomicBoolean;-><init>(Z)V

    iput-object p1, p0, Lcom/felhr/usbserial/UsbSerialDevice$WriteThread;->working:Ljava/util/concurrent/atomic/AtomicBoolean;

    return-void
.end method


# virtual methods
.method public run()V
    .locals 5

    .line 304
    :cond_0
    :goto_0
    iget-object v0, p0, Lcom/felhr/usbserial/UsbSerialDevice$WriteThread;->working:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v0

    if-eqz v0, :cond_1

    .line 306
    iget-object v0, p0, Lcom/felhr/usbserial/UsbSerialDevice$WriteThread;->this$0:Lcom/felhr/usbserial/UsbSerialDevice;

    iget-object v0, v0, Lcom/felhr/usbserial/UsbSerialDevice;->serialBuffer:Lcom/felhr/usbserial/SerialBuffer;

    invoke-virtual {v0}, Lcom/felhr/usbserial/SerialBuffer;->getWriteBuffer()[B

    move-result-object v0

    .line 307
    array-length v1, v0

    if-lez v1, :cond_0

    .line 308
    iget-object v1, p0, Lcom/felhr/usbserial/UsbSerialDevice$WriteThread;->this$0:Lcom/felhr/usbserial/UsbSerialDevice;

    iget-object v1, v1, Lcom/felhr/usbserial/UsbSerialDevice;->connection:Landroid/hardware/usb/UsbDeviceConnection;

    iget-object v2, p0, Lcom/felhr/usbserial/UsbSerialDevice$WriteThread;->outEndpoint:Landroid/hardware/usb/UsbEndpoint;

    array-length v3, v0

    const/16 v4, 0x1388

    invoke-virtual {v1, v2, v0, v3, v4}, Landroid/hardware/usb/UsbDeviceConnection;->bulkTransfer(Landroid/hardware/usb/UsbEndpoint;[BII)I

    goto :goto_0

    :cond_1
    return-void
.end method

.method public setUsbEndpoint(Landroid/hardware/usb/UsbEndpoint;)V
    .locals 0

    .line 314
    iput-object p1, p0, Lcom/felhr/usbserial/UsbSerialDevice$WriteThread;->outEndpoint:Landroid/hardware/usb/UsbEndpoint;

    return-void
.end method

.method public stopWriteThread()V
    .locals 2

    .line 319
    iget-object v0, p0, Lcom/felhr/usbserial/UsbSerialDevice$WriteThread;->working:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    return-void
.end method
